/**
 *****************************************************************************************************
 * @copyright	(c)  Shenzhen Saiyuan Microelectronics Co., Ltd
 * @file	SysFunVarDefine.h
 * @author
 * @version
 * @date
 * @brief	Store var control and function control extern
 * @details
 *****************************************************************************************************
 * @attention
 *
 *****************************************************************************************************
 */
#pragma once

#include "CustomType.h"
#include "UserExport.h"
#include "FunctionType.h"
#include "CompCtrlDefine.h"
#include "U8G2\u8g2.h"
#define Base_Year 2000

/**************************************Generated by EasyCodeCube*************************************/
//Forbid editing areas between the labels !!!

/*************************************.Generated by EasyCodeCube.************************************/
typedef enum
{
    PEN_CLEAR = 0x00,
    PEN_WRITE = 0x01,
    PEN_INVERSION = 0x02,
} pen_typedef;
typedef struct
{
    unsigned char Sec;
    unsigned char Min;
    unsigned char Hour;
    unsigned char Day;
    unsigned char Month;
    unsigned char Year;
    unsigned char Week;
} CLOCK;
typedef enum
{
    Left = 0,
    Right,
    Up,
    Down,
    Set,
    Buds_Num
} Typedef_Enum_Buds;
typedef enum
{
    Front_Check = 0,
    Clock, // 闹钟操作
    Func,
    id,
    opt,
    month,
    day,
    hour,
    minute,
    second,
    End_Check,
    Num_Typedef_Enum_Communication_Alarm
} Typedef_Enum_Communication_Alarm;
typedef enum
{
    Red = 1,
    Green,
    Blue,
    Randdom
} Typedef_Enum_Light_Choose;
extern volatile unsigned char TWI0Flag;
extern unsigned char TWI0SendData;
extern unsigned char US0_UART_ReceiveData;
extern unsigned char Init_Finish;
extern unsigned char TxData[11];
extern unsigned char RxData[11];
extern unsigned char Buds[Buds_Num];
extern u8g2_t u8g2;
extern int Light_Choose;
#define OLED_I2C_ADDRESS 0x78

// the resolution of oled   128*64
#define MAX_COLUMN 128
#define MAX_ROW 64

#define X_WIDTH MAX_COLUMN
#define Y_WIDTH MAX_ROW

#define OLED_CMD 0x00
#define OLED_DATA 0x01

#define CHAR_SIZE_WIDTH 6
#define CHAR_SIZE_HIGHT 12

#define Systick_Limit 4000000000

void OLED_display_on(void);
void OLED_display_off(void);
void OLED_operate_gram(pen_typedef pen);
void OLED_set_pos(uint8_t x, uint8_t y);
void OLED_draw_point(int8_t x, int8_t y, pen_typedef pen);
void OLED_draw_line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, pen_typedef pen);
void OLED_show_char(uint8_t row, uint8_t col, uint8_t chr);
void OLED_show_string(uint8_t row, uint8_t col, uint8_t *chr);
void OLED_refresh_gram(void);
void OLED_LOGO(void);
void delay(uint16_t cnt);
void OLED_Clear(void);
void OLED_ColorTurn(uint8_t ColorValue);
void OLED_DisplayTurn(uint8_t TurnValue);
void OLED_Init(void);
void OLED_ShowByte(uint8_t x, uint8_t y, uint8_t input);
void oled_write_byte(uint8_t dat, uint8_t mode);
void TWI_SendByte(uint8_t SendByte);
void TWI_Start(void);
void TWI_Stop(void);
void Delay_ms(uint32_t ms);
void Delay_us(uint32_t us);
void OLED_printf(uint8_t row, uint8_t col, const char *fmt, ...);
uint8_t u8x8_byte_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_gpio_and_delay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
void u8g2Init(u8g2_t *u8g2);
void OLED_Draw_Picture(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char BMP[]);
void OLED_Reverse(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1);
void OLED_Shift_Vertical(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char direction);
void OLED_Shift_Up(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1);
void OLED_Shift_Down(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1);
